package face.wis.wisfacedemo4android;

import android.os.Environment;
import android.provider.ContactsContract;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.wis.face.WisMobile;
import com.wis.face.WisUtil;
import java.io.File;

public class MainActivity extends AppCompatActivity {

    /******加载人脸引擎,请将,sdk文件夹下的wis目录 全部拷贝到/sdcard/下****/
    private static  WisMobile wisMobile;
    public static final String modelDir = "/sdcard/wis";
    static {
        System.loadLibrary("caffe");
        System.loadLibrary("wis_engine_jni");
        wisMobile = new WisMobile();
        wisMobile.setNumThreads(4);
        wisMobile.loadModel(modelDir);//modelDir为wis所在的目录
    }
    /**** 人脸引擎加载完毕 */

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        demo();
    }

    private void demo()
    {
        String SerialNo = wisMobile.getSerialNo();
        Log.i("face", "SerialNo = " + SerialNo);

        String fileName1 = "/sdcard/wis/images/1001.jpg";
        String fileName2 = "/sdcard/wis/images/1002.jpg";
        String fileName3 = "/sdcard/wis/images/1003.jpg";
        //compare 2 faces
        float score = wisMobile.calculate2ImageSimilarity(fileName1, fileName2);
        Log.i("face", "1&2 Similarity Score=" + score);
        score = wisMobile.calculate2ImageSimilarity(fileName2, fileName3);
        Log.i("face", "2&3 Similarity Score=" + score);
        score = wisMobile.calculate2ImageSimilarity(fileName1, fileName3);
        Log.i("face", "1&3 Similarity Score=" + score);

        score = wisMobile.calculate2ImageSimilarity("/sdcard/wis/images/1.jpg", "/sdcard/wis/images/2.jpg");
        Log.i("face", "1&3 Similarity Score=" + score);
    }
}
